package com.tang.portal.component.harbor

import com.alibaba.fastjson2.JSON
import com.tang.common.model.req.ReqPage
import com.tang.portal.component.harbor.core.HarborBaseService
import com.tang.portal.component.harbor.model.Repository
import org.apache.http.client.methods.HttpGet
import org.springframework.stereotype.Component

/**
 * @author tang jun liang
 * @Date 2023/6/21 15:05
 */
@Component
class HarborRepositoryService : HarborBaseService() {


    fun repositories(projectName: String, page: ReqPage): List<Repository> {
        val httpGet: HttpGet = HttpGet("${getHarborConfigProperties().url}/Tag/v2.0/projects/${projectName}/repositories?page=${page.pageNum}&page_size=${page.pageSize}");
        val result = execute(httpGet);
        return JSON.parseArray(result, Repository::class.java);
    }
}
